home *** CD-ROM | disk | FTP | other *** search
- /* vfprintf.c --- p 474 */
- #include <stdio.h>
- #include <stdarg.h>
- char filename[80] = "EXAMPLE.EXE";
- main()
- {
- int line_no = 131;
- /* Call the error handler to print an error message.
- * First just a single line. Then a more detailed
- * message with more arguments. */
- my_errmsg("Syntax error\n");
- my_errmsg("File: %s at line_no %d\n", filename,
- line_no);
- }
- /*-------------------------------*/
- /* my_errmsg: accepts variable number of arguments
- * and prints their values to stderr */
- my_errmsg(char *p_format)
- {
- va_list p_arg;
- /* Use va_start followed by va_arg macros to get to the
- * start of the variable number of arguments. This will
- * alter the pointer p_arg to point to the list of
- * variables to be printed. */
- va_start(p_arg, p_format);
- vfprintf(stderr, p_format, p_arg);
- /* Use the va_end macro to reset the p_arg to NULL */
- va_end(p_arg);
- }